<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<IEnumerable<TheWorldsWorst.ApiWrapper.Model.Tag>>" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Tags by <%= ViewData["SortOrder"] %> page #<%= ViewData["PageNum"] %></title>
    <link rel="Stylesheet" href="../../Content/Site.css" />
</head>
<body>
    <div>
        <a href="/"><img style="border-style: none" src="../../Content/img/logo.png" /></a>
    </div>
    <div>
    <%
        string nameStyle, popularStyle;
        if (ViewData["SortOrder"].Equals("name"))
        {
            nameStyle = "selected-tab";
            popularStyle = "unselected-tab";
        }
        else
        {
            nameStyle = "unselected-tab";
            popularStyle = "selected-tab";
        }
    %>
        <a href="/listtags?sortorder=name"><span class="<%= nameStyle %>">Name</span></a>
        <a href="/listtags?sortorder=popular"><span class="<%= popularStyle %>">Popular</span></a>
    </div>
    <div>
        <form method="get" action="/listtags">
        Find: <input name="filter" type="text" />
        <input type="hidden" name="sortorder" value="<%= ViewData["SortOrder"] %>" />
        <input type="submit" value="Search" />
        </form>
    </div>
    
    <div>
    <% foreach (var t in Model)
       {
           var tag = t.Name;
           var count = t.Count;
           %>
            <a href="/tags/<%= tag %>"><span class="tag"><%= tag %></span>x <%= count %></a>
            <br />
    <% } %>
    </div>
    
    <div>
    <% if ((int)ViewData["PageNum"] > 1)
       { %>
        <a href="/listtags?filter=<%= ViewData["Filter"] %>&sortorder=<%= ViewData["SortOrder"] %>&pagesize=<%= ViewData["PageSize"] %>&pagenum=<%= (int)ViewData["PageNum"] - 1 %>">Previous Page</a>
    <% } %>
    <% if ((int)ViewData["PageSize"] == Model.Count())
       { %> 
        <a href="/listtags?filter=<%= ViewData["Filter"] %>&sortorder=<%= ViewData["SortOrder"] %>&pagesize=<%= ViewData["PageSize"] %>&pagenum=<%= (int)ViewData["PageNum"] + 1 %>">Next Page</a>
    <% } %>
    </div>
</body>
</html>
